<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Page-Exit" content="revealTrans(Duration=0.1,Transition=2)"/>
		<meta http-equiv="Page-Enter" content="revealTrans(Duration=0.1,Transition=2)"/>
		<title>苏州市公安表彰奖励管理平台</title>
		<link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/login.css'/>" />
		<%
		String u= request.getHeader("host");
		if(u.indexOf(":")>-1)
		{
		 u=u.substring(0,u.indexOf(":"));
		}
		String ctx = request.getContextPath();
		String url = request.getRequestURI();
		String code = request.getRemoteUser();
	    %>  
		<script type="text/javascript" src="<c:url value='/resource/js/jquery-1.7.2.min.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/js/jquery-caplocktip.js'/>"></script>
		<script type="text/javascript">
			var debounce = function (func, threshold, execAsap) {  
			    var timeout;  
			    return function debounced () {  
			        var obj = this, args = arguments;  
			        function delayed () {  
			            if (!execAsap)  
			            func.apply(obj, args);  
			            timeout = null;  
			        };  
			        if (timeout)  
			            clearTimeout(timeout);  
			        else if (execAsap)  
			            func.apply(obj, args);  
			        timeout = setTimeout(delayed, threshold || 100);  
			    };  
			};
			window.onresize = debounce(function(){  
			   $("#main").css("margin-top",($(window).height()-500)/2-30);
			}, 100, true);
			
			function isBlank(targetCmpId,msgCmpId,msg){
				if ("" == $("#"+targetCmpId).val().replace(/(^\s*)|(\s*$)/g, "")) {
					$("#"+msgCmpId).text(msg);
					return false;
				}else{
					$("#"+msgCmpId).text("");
					return true;
				}
			}
			
			function trimStr(targetCmpId){
				return $("#"+targetCmpId).val().replace(/(^\s*)|(\s*$)/g, ""); 
			}
		
			document.onkeydown = function() {
				if (13 == event.keyCode) {
					if(isBlank("username","userErr","请输入用户名！") && isBlank("password","userErr","请输入密码！")){
						$.post("<c:url value='/profile/auth.json'/>",{policeNum:trimStr("username"),password:trimStr("password")},function(data){
							if(1 == data.msg.status){
							
							alert("<c:url value='/profile/admin.html'/>")
								window.location.replace("<c:url value='/profile/admin.html'/>");
							}else{
								$("#userErr").text(data.msg.body);
							}
						});
					}
				}
			};
			$(function(){
				$("#main").css("margin-top",($(window).height()-500)/2-30);
				$("#btn_login").click(function(){
					if(isBlank("username","userErr","请输入用户名！") && isBlank("password","pwdErr","请输入密码！")){
						$.post("<c:url value='/profile/auth.json'/>",{policeNum:trimStr("username"),password:trimStr("password")},function(data){
							if(1 == data.msg.status){
								window.location.replace("<c:url value='/profile/admin.html'/>");
							}else{
								$("#userErr").text(data.msg.body);
							}
						});
					}
					return;
				});
				//key登录
				$("#keylogin").click(function(){
					   alert("https://<%=u%>:80<%=ctx%>/ca.jsp");
					   window.location.href = encodeURI("https://<%=u%>:8442<%=ctx%>/ca.jsp");
					});
			});
		</script>
	</head>
	<body >
		<div id="container">
			<div id="main">
				<div class="login_name">
			    	<label class="login_name_" style="height:25px;margin-top:3px;font-family:楷体 微软雅黑;font-size:16px;">用户名：</label>
			    	<input type="text" id="username" name="policeNum" value="100000" maxlength="15" class="input_name_" style="font-family:微软雅黑;font-size:16px;" onblur="isBlank('username','userErr','请输入用户名！');"/>
			  		<label id="userErr" style="width:125px;height:30px;line-height:30px;font-size:12px;color:#fff;text-align:left;"></label>
			    </div>
			  	<div class="login_password">
			  		<label class="login_password_" maxlength="15" style="height:25px;margin-top:3px;font-family:楷体 微软雅黑;font-size:16px;">密　码：</label>
			    	<input type="password" id="password" name="password" value="123456" maxlength="15" class="input_password_" style="font-size:16px;font-weight:bold;" onblur="isBlank('password','pwdErr','请输入密码！');"/>
			  		<label id="pwdErr" style="width:125px;height:30px;line-height:30px;font-size:12px;color:#fff;text-align:left;"></label>
			    </div>
			    <div class="login_btn">
			    	<div class="btn_login"><a id="btn_login" href="javascript:;"></a></div>
			        <div class="btn_reset"><a id="keylogin" href="javascript:;"></a></div>
			    </div>
			</div>
			<div class="login_footer"><a>版权所有©苏州市公安局　　技术支持：江苏欧索软件有限公司</a></div>
		</div>
	</body>
</html>